package net.tavion.angelboot.bsm.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import net.tavion.angelboot.bsm.dto.*;
import net.tavion.angelboot.common.vo.GenericResponse;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("agw/")
@Slf4j
public class BsmAgwController {

    @ApiOperation(value = "用户登录校验", notes = "网关调用")
    @ApiResponse(code = 200, message = "登录结果")
    @PostMapping("/userlogin")
    public GenericResponse<CustomerLoginRspDTO> login(@RequestBody CustomerLoginReqDTO loginParams){
        log.info("=========================username================={}",loginParams.getUsername());
        log.info("=========================password================={}",loginParams.getPassword());


        CustomerLoginRspDTO customerLoginRspDTO=new CustomerLoginRspDTO();
        customerLoginRspDTO.setUsername(loginParams.getUsername());
        customerLoginRspDTO.setLoginUsername("tavion");
        customerLoginRspDTO.setValidPassword("12345");
        return new GenericResponse(customerLoginRspDTO) ;
    }


    @ApiOperation(value = "用户信息查询", notes = "网关调用")
    @ApiResponse(code = 200, message = "用户信息查询结果")
    @PostMapping("/userInfo")
    public Mono<GenericResponse<CustomerInfoDTO>> info(@RequestBody CustomerReqDTO queryDTO){
        CustomerInfoDTO customerInfoDTO=new CustomerInfoDTO();
        customerInfoDTO.setPhoneNo("13799710091");
        customerInfoDTO.setUserid(1900977212);
        customerInfoDTO.setUsername("方丈");
        return Mono.just(new GenericResponse(customerInfoDTO));
    }

    @ApiOperation(value = "系统密钥查询校验", notes = "网关调用")
    @ApiResponse(code = 200, message = "系统密钥查询校验结果")
    @PostMapping("/validKey")
    public Mono<GenericResponse<SystemKeyInfoDTO>> validKey(@RequestParam("channelKey") String channelKey){


        SystemKeyInfoDTO systemKeyInfoDTO =new SystemKeyInfoDTO();
        systemKeyInfoDTO.setChannelKey(channelKey);
        systemKeyInfoDTO.setVersion("1.0.0");
        systemKeyInfoDTO.setSignMode("SHA");
        systemKeyInfoDTO.setChannelCode("WEB");
        return Mono.just(new GenericResponse(systemKeyInfoDTO));
    }

    public Mono<String> sayHi() {
        return Mono.just("Hi");
    }
}
